

def get_presum(a):
    n = len(a)
    sum = [0] * n
    sum[0] = a[0]
    for i in range(1,n):
        sum[i] = sum[i-1] + a[i]
    return sum

#from l to r, including l and r
def get_sum(sum, l , r):
    if l == 0:
        return sum[r]
    return sum[r] - sum[l-1]


a = [1,2,3,4,5]
print(*get_presum(a))
print(get_sum(get_presum(a), 1,3))

